let tools={
  //格式化日期
  FormData:(data,format='yyyy-MM-dd hh:mm:ss')=>{
    let time = new Date()
    //如果传入是年月日直接赋值
    if(typeof data=='Date'){
      time=data;
    }else{
      //否则就是时间戳
      time.setTime(data);
    }
    //获取分区时间
    let y=time.getFullYear();
    let m=time.getMonth()+1;
    let d=time.getDate();
    let h=time.getHours();
    let mm=time.getMinutes();
    let s=time.getSeconds();
    //格式化
    let result=format.replace(/yyyy/g,y);
    result = result.replace(/MM/g,m);
    result = result.replace(/dd/g,d);
    result = result.replace(/hh/g,h);
    result = result.replace(/mm/g,mm);
    result = result.replace(/ss/g,s);
    return result;
  },
  //合并多个json为一个,...是不定长参数
  concatJson:(...jsons)=>{
    let result={};
    for (let i = 0; i < jsons.length; i++) {
      const json = jsons[i];
      //json对象的key循环
      for(let key in json){
      console.log(key,json[key]);

      result[key]=json[key];
      }
    }

    return result;
  }
};

export default tools;